package com.bone.workstation.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bone.common.BaseIbatisDAO;
import com.bone.page.Page;
import com.bone.workstation.po.Employee;
import com.bone.workstation.po.Role;


/**
 * DAO.
 * @author liwenzhan
 *
 */
public class EmployeeDAO extends BaseIbatisDAO {

	/**
	 * 取符合条件的模块的数量.
	 * @param para
	 * @return
	 */
	public Long queryEmployeeCountByParam(Map<String, Object> para){
		return (Long) getSqlMapClientTemplate().queryForObject("EMPLOYEE.queryEmployeeCountByParam", para);
	}
	/**
	 * 取符合条件的模块的LIST.
	 * @param para
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Employee> queryEmployeePageByParam(Map<String, Object> para){
		return getSqlMapClientTemplate().queryForList("EMPLOYEE.queryEmployeePageByParam", para);
	}
	
	/**
	 * 取用户的角色列表数据.
	 * @param parameter
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Employee> queryEmployeeListByParam(Map<String, Object> para){
		return getSqlMapClientTemplate().queryForList("EMPLOYEE.queryEmployeeListByParam", para);
	}
	
	/**
	 * .
	 * @param objectId
	 * @return
	 */
	public Employee queryEmployeeByParam(Employee employee){
		Employee emp = new Employee();
		Map<String, Object> para = new HashMap<String, Object>();
		para.put("account", employee.getAccount());
		para.put("password", employee.getPassword());
		List<Employee> list = this.queryEmployeeListByParam(para);
		if(list!=null && list.size()>0){
			emp = list.get(0);
		}
		return emp;
	}

	/**
	 *  按PK取Employee.
	 * @param parameter
	 * @return
	 */
	public Employee queryByEmployeeId(Long employeeId){
		return  (Employee) super.getSqlMapClientTemplate().queryForObject("EMPLOYEE.queryByPaymentId", employeeId);
	}
	 
    /**
     * 保存和修改.	
     * @param employee
     */
	public void saveOrUpdateEmployee(Employee employee){
	   if(employee.getEmployeeId()!=null && employee.getEmployeeId()>0){
		   getSqlMapClientTemplate().update("EMPLOYEE.update", employee);
	   }else{
		   getSqlMapClientTemplate().insert("EMPLOYEE.insert", employee);
	   }
	}
	
	 
	
	/**
	 *  根据订单ID和状态查询支付成功的记录.
	 * @param objectId
	 * @return
	 */
//	public List<PayPayment> selectPaymentListByParas(final Long objectId, String bizType){
//		Map<String, Object> map = new HashMap<String, Object>();
//		map.put("objectId",objectId);
//		map.put("status", Constant.PAYMENT_SERIAL_STATUS.SUCCESS.name());
//		map.put("bizType", bizType);
//		map.put("orderby", "AMOUNT");
//		return super.getSqlMapClientTemplate().queryForList("PAY_PAYMENT.selectPaymentListByParas", map);
//		
//	}
	/**
	 *  根据条件查询相关记录.
	 * @param objectId
	 * @return
	 */
//	public List<PayPayment> selectPaymentListByMap(final  Map<String, Object> map){
//		map.put("orderby", "CREATE_TIME");
//		map.put("order", "DESC");
//		return super.getSqlMapClientTemplate().queryForList("PAY_PAYMENT.selectPaymentListByParas", map);
//	}
//	
//	public PayPayment selectBySerial(String serial) {
//		return (PayPayment) super.getSqlMapClientTemplate().queryForObject(
//				"PAY_PAYMENT.selectBySerial", serial);
//	}
//	
//	public Long sumPayedOrdPaymentAmountByObjectId(Long objectId) {
//		return (Long) super.getSqlMapClientTemplate().queryForObject(
//				"PAY_PAYMENT.sumPayedOrdPaymentAmountByObjectId", objectId);
//	}
	/**
	 * 
	 * @param objectId
	 * @param objectType
	 * @return
	 */
//	public List<PayPayment> selectByObjectIdAndBizType(Long objectId, String objectType){
//		Map<String, Object> paras = new HashMap<String, Object>();
//		paras.put("objectId", objectId);
//		paras.put("bizType", objectType);
//		return super.getSqlMapClientTemplate().queryForList("PAY_PAYMENT.selectByObjectIdAndBizType", paras);
//	}
//	/**
//	  * 根据objectId查询所有的支付记录和预授权的记录.
//	  * @param objectId
//	  * @param bizType
//	  * @return
//	  */
//	public List<PayAndPrePaymentVO> selectPayAndPreByObjectIdAndBizType(Long objectId, String bizType){
//		Map<String, Object> paras = new HashMap<String, Object>();
//		paras.put("objectId", objectId);
//		paras.put("bizType", bizType);
//		return super.getSqlMapClientTemplate().queryForList("PAY_PAYMENT.selectPreAndPayByObjectIdAndBizType", paras);
//	}
//	
//	public Long selectPaymentSuccessCount(Long objectId) {
//		return (Long) super.getSqlMapClientTemplate().queryForObject(
//				"PAY_PAYMENT.selectPaymentSuccessCount", objectId);
//	}
//

}
